﻿using Microsoft.VisualBasic;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Data;
using System.Diagnostics;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Drawing;
using System.Data.SqlClient;
using System.Web.Services;
using System.Web.Services.Protocols;
using System.Net.Mail;
using System.Net;

public class Cutilidades
{




	public static void ShowMessage(System.Web.UI.Page objWebPage, string strMessage)
	{
		try {
			string strScript = null;
			Guid guidKey = new Guid();
			IFormatProvider objCulture = null;
			objCulture = new System.Globalization.CultureInfo("es-CO", true);

			strMessage = strMessage.Replace("'", "");
			strMessage = strMessage.Replace(" ", "");

			strScript = "<script type='text/javascript' >" + "var strMultiLine='" + strMessage + "' ; " + "var strLine=strMultiLine.replace(new RegExp('\\\\n','g'),'...' ); " + "strLine=strMultiLine.replace(new RegExp('\"','g'),'...' ); " + "alert(strLine);" + "</script>";
			if (objWebPage.ClientScript.IsStartupScriptRegistered(guidKey.ToString()) == false) {
				objWebPage.ClientScript.RegisterStartupScript(objWebPage.GetType(), guidKey.ToString(), strScript);
			}

		} catch (Exception ex) {
			throw;
		}

	}

	public static void ShowMessageBoxWithRedirect(System.Web.UI.Page objWebPage, string strMessage, string strPageURLToRedirect)
	{
		try {
			string strScript = null;
			strMessage = strMessage.Replace("'", "");

			strScript = "<script type='text/javascript' >" + "alert('" + strMessage + "');" + "window.location.href=('" + strPageURLToRedirect + "');" + "</script>";
			if (objWebPage.ClientScript.IsStartupScriptRegistered("ShowMessageBoxWithRedirect") == false) {
				objWebPage.ClientScript.RegisterStartupScript(objWebPage.GetType(), "ShowMessageBoxWithRedirect", strScript);
			}


		} catch (Exception ex) {
			throw;
		}

	}
    

	public static void WindowOpen(System.Web.UI.Page objWebPage, string Url, string WindowProperties)
	{
		try {
			string ClientScript = "<script >window.open('" + Url + "','','" + WindowProperties + "')</script>";

			if (objWebPage.ClientScript.IsStartupScriptRegistered("WOpen") == false) {
				objWebPage.ClientScript.RegisterStartupScript(objWebPage.GetType(), "WOpen", ClientScript);
			}

		} catch (Exception ex) {
			Cutilidades.ShowMessage(objWebPage, "Se ha presentado el siguiente error " + ex.Message + " en el metodo WindowOpen");
		}

	}


	public static void WindowClose(System.Web.UI.Page objWebPage, string Url, string ClientScript)
	{

		if (objWebPage.ClientScript.IsStartupScriptRegistered("WClose") == false) {
			objWebPage.ClientScript.RegisterStartupScript(objWebPage.GetType(), "WClose", ClientScript);
		}

	}




	public static void AddItemToDropDownList(DropDownList cboDropDownList, string strText, string strValue, bool blnAddFirstItem)
	{
		ListItem objListItem = new ListItem();
		objListItem.Text = strText;
		objListItem.Value = strValue;

		if (blnAddFirstItem == true) {
			cboDropDownList.Items.Insert(0, objListItem);
		} else {
			cboDropDownList.Items.Insert(cboDropDownList.Items.Count + 1, objListItem);
		}

	}

	#region "Reportes"



	#endregion

}
